<?php
class SessionManager extends CI_Model {
    public function __construct()
    {
		$this->load->model('DatabaseManager');
        parent::__construct();
    }
	//  检查session	username(学号) sessionId(客户端保存的session)  
	public function check($username,$sessionId)
    {
		if($sessionId==null){
				return false;	
		}
		//		get($username)  获取服务器存储的session
		if($this->get($username)!=$sessionId){
			return false;		
		}
		return true;
    }
	public function get($user)
    {
    	$row=$this->DatabaseManager->get_session($user);
		return $row['sessionId'];
    }
	public function set($user,$name)
    {
		$code='!express';
		$s=md5($user.$name.$code.time());
		$this->DatabaseManager->set_session($user,$s);
		return $s;
    }
	
}
?>